package com.hkts.flow.interceptor;

import feign.RequestInterceptor;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassNameFlowAbleInterceptor
 * @Description
 * @Author yck
 * @Date2021-02-01 11:46
 * @Version V1.0
 **/
public class FlowAbleInterceptor implements HandlerInterceptor {
    public static ThreadLocal<Map<String,Object>> toThreadLocal = new ThreadLocal<>();

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        String accessToken = request.getHeader("accessToken");

        if(StringUtils.isNotBlank(accessToken)){
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("accessToken",accessToken);
            toThreadLocal.set(map);
        }
        return true;

    }
}
